<template>
  <div>
    <el-tree :data="menus" :props="defaultProps"
             :expand-on-click-node="false"
             node-key="catId"
             :default-expanded-keys="expanded"
              ref="menuTree"
             @node-click="nodeClick">
    </el-tree>
  </div>
</template>

<script>
export default {
  name: 'category',
  created () {
    this.getMenus()
  },
  data () {
    return {
      PId:[],
      draggable:false,
      update:[],//保存需要更新的节点信息(兄弟节点 子节点可能变化)
      maxLevel:0,
      title: '',
      dialogType: '',//edit,add
      expanded: [],
      menus: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      dialogVisible: false,
      category: {
        name: '',
        parentCid: 0,
        catLevel: 0,
        showStatus: 1,
        sort: 0,
        icon: null,
        productUnit: null
      },
    }
  },
  methods: {
    nodeClick(data,node,component){
        this.$emit("tree-node-click",data,node,component)
    },
    getMenus () {
      this.$http({
        url: this.$http.adornUrl('/product/category/list/tree'),
        method: 'get',
      }).then(({data}) => {
        this.menus = data.data
        console.log('成功获取到菜单数据...' + data.data)
      })
    },
  }
}
</script>

<style scoped>

</style>
